import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

// 当前选择的器部件
export const useStionConfigStore = defineStore('useStionConfigStore', () => {
  const stionConfigState = ref({
    equipType: '', // 当前拖拽的器部件类型
    equipData: {}, // 当前拖拽的器部件数据
    dragData: {}, // 当前拖拽的器部件数据
    configData: {}, // 当前拖拽的器部件配置
    configDataSaveLoading: false, // 保存器部件信息loading
    dragging: false, // 拖拽中
    isEditDrag: false, // 是否编辑拓扑图
    draggableElment: [], // 拖拽器部件
  })
  function changeSupplierId(data) {
    stionConfigState.value.supplierId = data
  }
  function changeEquipType(data) {
    stionConfigState.value.equipType = data
  }
  function changeEquipData(data) {
    stionConfigState.value.equipData = data
  }
  function changeDragData(data) {
    stionConfigState.value.dragData = data
  }
  function changeConfigData(data) {
    stionConfigState.value.configData = data
  }
  function changeConfigDataSaveLoading(data) {
    stionConfigState.value.configDataSaveLoading = data
  }
  function changeDragging(data) {
    stionConfigState.value.dragging = data
  }
  function changeIsEditDrag(data) {
    stionConfigState.value.isEditDrag = data
  }
  function changeDraggableElment(data) {
    stionConfigState.value.draggableElment = data
  }
  
  return {
    stionConfigState,
    changeEquipType,
    changeDragData,
    changeConfigData,
    changeEquipData,
    changeConfigDataSaveLoading,
    changeDragging,
    changeIsEditDrag,
    changeDraggableElment
  }
})
